#include "./util.hpp"
#include "data.hpp"
#include "server.hpp"

void FileTest()
{
    aod::FileUtil("./www").CreateDirectory();
    aod::FileUtil("./www/index.html").SetContent("<html></html>");
    std::string body;
    aod::FileUtil("./www/index.html").GetContent(&body);
    std::cout<<body<<std::endl;
    std::cout<<aod::FileUtil("./www/index.html").FileSize()<<std::endl;
}

void JsonTest()
{
    Json::Value val;
    val["姓名"] = "小6";
    val["年龄"] = "18";
    val["性别"] = "男";
    val["成绩"].append(77.5);
    val["成绩"].append(88.5);
    val["成绩"].append(99.5);
     
    std::string body;
    aod::JsonUtil::Serialize(val,&body);
    std::cout<<body<<std::endl;

    Json::Value stu;
    aod::JsonUtil::UnSerialize(body,&stu);
    std::cout<< stu["姓名"].asCString() <<std::endl;
    std::cout<< stu["年龄"].asCString() <<std::endl;
    std::cout<< stu["性别"].asCString() <<std::endl;
    for(auto &a:stu["成绩"]){
        std::cout<<a.asFloat()<<std::endl;
    }
}

void DataTest()
{
    aod::TableVideo tb_video;
    Json::Value video;
    // video["name"]="更新";
    // video["info"]="444";
    // video["video"]="/video/up.ma4";
    // video["image"]="/image/up.jpg";
    // //tb_video.Insert(video);
    // tb_video.Update(2,video);
    std::string body; 
    //tb_video.SelectAll(&video);
    //tb_video.SelectOne(1,&video);
    //tb_video.SelectLike("更新",&video);
    //aod::JsonUtil::Serialize(video,&body);
    //std::cout<<body<<std::endl;
    tb_video.Delete(2);
}

void ServerTest()
{
    aod::Server server(8088);
    server.RunMoudule();
}

int main()
{
    ServerTest();
    return 0;
}